package exam.t4;

public class SLList2 {
    Node head;
    int num=0;
    public static class Node{
        int data;
        Node next;

        public Node(int data) {
            this.data = data;
        }

        public int getData() {
            return data;
        }

        public void setData(int data) {
            this.data = data;
        }

        public Node getNext() {
            return next;
        }

        public void setNext(Node next) {
            this.next = next;
        }
    }
    SLList2(int a[]){
        for (int i = 0; i < a.length; i++) {
            addLast(i);
        }
    }
    public int size(){
        return this.num;
    }
    public void addLast(int data){
        Node node =new Node(data);
        if(this.head==null){
            this.head=node;
        }else{
            Node tmp=this.head;
            while (tmp.getNext()!=null){
                tmp=tmp.getNext();
            }
            tmp.setNext(node);
        }
        num++;
    }
}
